<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}帖子详情</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__CSS__/AdminLTE.css" rel="stylesheet" type="text/css" />
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
     
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
      <style>
		.num,.current{padding:10px;display:inline-block;}
	.isShow,.del{cursor:pointer;}
	.btns,.isShow{padding:5px 15px; border:#ccc solid 1px; margin:10px;text-indent:0px;border-radius:3px; cursor:pointer}
	</style>
	<script>
		//删除单个帖子评论
	    function delComment(id){
		   var id = id;
		   Plugins.confirm({title:'信息提示',content:'您确定要删除该评论吗?',okText:'确定',cancelText:'取消',okFun:function(){
		   	Plugins.closeWindow();
		   	Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			   $.post("{:U('Admin/Posts/delComment')}",{id:id},function(data){
				  if(data.status==0){
					  Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
							location.reload();
						}});
				  }else{
                    Plugins.closeWindow();
          Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
				  }
				});
			 }});
	    }
	</script>
   </head>
   <body class='wst-page'>
      <style>
       #posts th{text-align:right;}
       </style>
       <div class='wst-tbar' style='height:25px;'>
	       <button type="button" class="btn btn-primary" style="float:right" onclick='javascript:location.href="{$referer}"'>返&nbsp;回</button>
	       </div>
       <div class="wst-body"> 
        <table class="table table-hover table-striped table-bordered wst-list" id="posts">
           <tbody>
             <tr>
                 <th style="width:110px; height:40px;">发布时间</th>
                 <td style="text-indent:10px;width:200px;">
                   {$object['posts']['ftime']}
                 </td>
                 <th style="width:110px; height:40px;">状态(单击修改)</th>
                 <td style="text-indent:10px;">
                   <span id="status" class="btns" data-id="{$object['posts']['id']}" data-status="{$object['posts']['status']}"> <if condition="$object['posts']['status'] eq 1">显示<else/>屏蔽</if></span>
                 </td>
             </tr>
             <tr>
                 <th style="width:110px; height:40px;">评论数 </th>
                 <td style="text-indent:10px;;">
                 {$object['posts']['comNum']}
                 </td>
                 <th style="width:110px; height:40px;">点赞数 </th>
                 <td style="text-indent:10px;">
                 {$object['posts']['dianNum']}
                 </td>
             </tr>
             <tr>
                <th style="width:110px; height:40px;">发帖人ID</th>
                <td style="text-indent:10px;">
                {$object['posts']['userId']}
                 </td>
                 <th style="width:110px; height:40px;">发帖人名称</th>
                 <td style="text-indent:10px;">
				<if condition="$object['posts']['userName'] neq ''">		
                	{$object['posts']['userName']}
                	<else />
                	{$object['posts']['loginName']}
                </if>
                 </td>
             </tr>
             <tr>
                 <th style="width:110px; height:40px;">分类</th>
                 <td style="text-indent:10px;" colspan="3">
                 {$object['posts']['cateName']}
                 </td>
             </tr>
             <tr>
                 <th style="width:110px; height:40px;">标题</th><td style="text-indent:10px;" colspan="3">{$object['posts']['title']}</td>
             </tr>
             <tr>
                 <th style="width:110px; height:40px;">内容</th><td style="text-indent:10px;" colspan="3">{$object['posts']['content']}</td>
             </tr>
            
           </tbody>
        </table>
        
        
          <table class="table table-hover table-striped table-bordered wst-list">
           <thead>
             <tr>
               <th width='40'>序号</th>
               <th width='80'>评论ID</th>
               <th width='100'>评论者</th>
               <th width='80'>评论人ID</th>
               <th width='160'>评论时间</th>
               <th>内容</th>
               <th width='110'>状态(双击修改)</th>
               <th width='70'>操作</th>
             </tr>
           </thead>
           <tbody>
           <volist name="object.comm.root" id="in" key='i'>
             <tr id="tr_{$in.id}">
               <td ><input type="checkbox" id="{$in.id}"  class="delid" value="{$in.id}"/>{$i}</td>
               <td >{$in.id}</td>
               <td >{$in.userName}</td>
               <td >{$in.userId}</td>
                <td>{$in.time}</td>
                <td style="word-break: break-all;">{$in.content}</td>
               <td  id="show_{$in.id}" data-id="{$in.id}" class="isShow"><if condition="$in['status'] eq 1">是<else/>否</if></td>
              <td  > <a class="del" onclick="javascript:delComment({$in.id});">删除</a></td>
             </tr>
             </volist>
             <tr style="">
                <td colspan='11'  style="padding:10px;" align='left'><span class="selectAll btns" data-status="0">全选/取消</span><span class="delAll btns">批量删除</span><span class="hideAll btns">批量隐藏</span><span class="showAll btns">批量显示</span></td>
             </tr>
             <tr>
                <td colspan='11' align='center'>{$object.comm.pager}</td>
             </tr>
           </tbody>
        </table>
        
       </div>
   </body>
   <script>
	   //修改帖子状态
	   $('body').on('click','#status',function(){
		   var _this=$(this);
		   var text=$(this).text();
		   var status=$(this).attr('data-status');
		   if(status==0){
			   status=1;
			   text='显示';
		   }else{
			   status=0;
			   text='隐藏';
		   }
		   var id=$(this).attr('data-id');
		   $.ajax({
				  type: "POST",
				  url: "{:U('Admin/Posts/editStatus')}",
				  data: {
				      id:id,
				      status:status
				  },
				  dataType: "json",
				  success: function(data){
					  if(data.status==0){
						  Plugins.Tips({title:'信息提示',icon:'error',content:'操作成功!',timeout:1000});
						  $(_this).text(text);
						  $(_this).attr('data-status',status);
					  }else{
						  Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
					  }
				  }
				});
	   })
   
	   
	    //批量删除帖子评论
	   $('body').on('click','.delAll',function(){
		   var id="";
		   $('.delid').each(function(){
			   if($(this).prop('checked')){
				   id+=$(this).val()+',';
			   }
		   })
		   id=id.substring(0,id.length-1);
		   if(!id){
			   layer.msg('请选择要删除的评论');return;
		   }
	   Plugins.confirm({title:'信息提示',content:'您确定要删除所选评论吗?',okText:'确定',cancelText:'取消',okFun:function(){
		   Plugins.closeWindow();
		   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			   $.ajax({
					  type: "POST",
					  url: "{:U('Admin/Posts/delSelectComment')}",
					  data: {
					      id:id
					  },
					  dataType: "json",
					  success: function(data){
						  if(data.status==0){
							Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
								var delItem=id.split(',');
								 for(var i=0;i<delItem.length;i++){
								  $('#tr_'+delItem[i]).remove();
								}
							}});
						  }else{
							Plugins.closeWindow();
							parent.showMsg({msg:'操作失败!',status:'danger'});
						  }
					  }
					});
			}});
	   })
	   //批量隐藏
	   $('body').on('click','.hideAll',function(){
		   var id="";
		   $('.delid').each(function(){
			   if($(this).prop('checked')){
				   id+=$(this).val()+',';
			   }
		   })
		   id=id.substring(0,id.length-1);
		   if(!id){
			   layer.msg('请选择要隐藏的评论');return;
		   }
	   Plugins.confirm({title:'信息提示',content:'您确定要隐藏所选评论吗?',okText:'确定',cancelText:'取消',okFun:function(){
		   Plugins.closeWindow();
		   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			   $.ajax({
					  type: "POST",
					  url: "{:U('Posts/hideSelectComment')}",
					  data: {
					      id:id
					  },
					  dataType: "json",
					  success: function(data){
						  if(data.status==0){
						  	Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
								var delItem=id.split(',');
								  for(var i=0;i<delItem.length;i++){
									  $('#show_'+delItem[i]).text('否');
								  }
							}});
						  }else{
							Plugins.closeWindow();
							parent.showMsg({msg:'操作失败!',status:'danger'});
						  }
					  }
					});
			 }})
	   })
	   //批量显示
	   $('body').on('click','.showAll',function(){
		   var id="";
		   $('.delid').each(function(){
			   if($(this).prop('checked')){
				   id+=$(this).val()+',';
			   }
		   })
		   id=id.substring(0,id.length-1);
		   if(!id){
			   layer.msg('请选择要处理的评论');return;
		   }
	   Plugins.confirm({title:'信息提示',content:'您确定要显示所选评论吗?',okText:'确定',cancelText:'取消',okFun:function(){
		   Plugins.closeWindow();
		   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			   $.ajax({
					  type: "POST",
					  url: "{:U('Posts/showSelectComment')}",
					  data: {
					      id:id
					  },
					  dataType: "json",
					  success: function(data){
						  if(data.status==0){
						  	Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
							  var delItem=id.split(',');
							  for(var i=0;i<delItem.length;i++){
								  $('#show_'+delItem[i]).text('是');
							  }
							}});
						  }else{
							Plugins.closeWindow();
							parent.showMsg({msg:'操作失败!',status:'danger'});
						  }
					  }
					});
			 }})
	   })
	   
	   $('.selectAll').on('click',function(){
		   var status=$(this).attr('data-status');
		   if(status==0){
			   $(this).attr('data-status',1);
			   $('.delid').each(function(){
				   $(this).prop('checked',true);
				   })
		   }else{
			   $(this).attr('data-status',0);
			   $('.delid').each(function(){
				   $(this).prop('checked',false);
				   })
		   }
	   })
	   //显示隐藏评论
	   $('body').on('dblclick','.isShow',function(){
		   var _this=$(this);
		   var text=$(this).text();
		   var status=0;
		   if(text=='否'){
			   status=1;
			   text="是";
		   }else{
			   status=0;
			   text="否";
		   }
		   var id=$(this).attr('data-id');
		   $.ajax({
				  type: "POST",
				  url: "{:U('Admin/Posts/showHideComment')}",
				  data: {
				      id:id,
				      status:status
				  },
				  dataType: "json",
				  success: function(data){
					  if(data.status==0){
						  //Plugins.Tips({title:'信息提示',icon:'error',content:'操作成功!',timeout:2000});
						  $(_this).text(text);
						  location.reload();
					  }else{
						  Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
					  }
				  }
				});
	   })
	   
   </script>
</html>